﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using Microsoft.TeamFoundation.MVVM;
//using System.Drawing;
using System.Windows;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
namespace Edytor.ModelViews
{
    public class NewMapWindowModelView : ViewModelBase
    {
        public event EventHandler CloseDelegate;

        private string _mapName;
        public string MapName
        {
            get { return _mapName ?? "default"; }
            set { _mapName = value; RaisePropertyChanged("MapName"); }
        }

        private Point _mapSize;
        public Point MapSize
        {
            get
            {
                if (_mapSize.X==0&&_mapSize.Y==0) _mapSize = new Point(32, 32);
                return _mapSize;
            }
            set { _mapSize = value; RaisePropertyChanged("MapSize"); }
        }

        private Point _tileSize;
        public Point TileSize
        {
            get
            {
                if (_tileSize.X==0&&_tileSize.Y==0) _tileSize = new Point(32, 32);
                return _tileSize;
            }
            set { _tileSize = value; RaisePropertyChanged("TileSize"); }
        }

        private bool _czyDodano;
        public bool CzyDodano
        {
            get { return _czyDodano; }
            set { _czyDodano = value; }
        }
        

        private RelayCommand _newMapButtonCommand;
        public RelayCommand NewMapButtonCommand
        {
            get
            {
                return _newMapButtonCommand ?? (_newMapButtonCommand = new RelayCommand(CreateNewMap, () => ValidateMapData()));
            }
            
        }

        private bool? _dialogResult;
        public bool? DialogResult
        {
            get { return _dialogResult; }
            set { _dialogResult = value; RaisePropertyChanged("DialogResult"); }
        }

        private void CreateNewMap()
        {
            CzyDodano = true;
            if (CloseDelegate != null)
                CloseDelegate(this, EventArgs.Empty);
        }
        private bool ValidateMapData()
        {
            if (!string.IsNullOrEmpty(MapName) && MapSize.X != 0 && MapSize.Y != 0 && TileSize.X != 0 && TileSize.Y != 0)
                return true;
            else return false;
        }

    }
}
